<?php
namespace app\mini\model;

use think\facade\Db;
use app\common\traits\ActionRecordTrait;
use think\Model;
use app\admin\controller\ApiCommon;

class MiniAppointmentModel extends Model
{
    /**

    * @var string

    */

    protected $name = 'admin_sys';



    protected $defaultSoftDelete = 0;



    protected $autoWriteTimestamp = true;

     
    public function getShopPerson($request): array
    {
        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;
        $shop_id = $request['shop_id'] ?? '';

        

        $where = [];

        array_push($where,['shop_id','=',$shop_id]);

        array_push($where,['position_id','in',[2,3,4,7,8,9,10]]);

        array_push($where,['status','=','1']); // 在职

        $staffList = Db::name('shop_person')->where($where)->column('id,name,station_name,position_name,shop_id');


        // 获取员工头像
        $shop_person_ids = array_values(array_unique(array_column($staffList,'id')));

        // echo "<pre>";
        // print_r($shop_person_ids);
        // echo "</pre>";
        // exit;

        $where = [];

        array_push($where,['shop_person_id','in',$shop_person_ids]);

        $shop_person_imgs = Db::name('admin_user')->where($where)->column('img','shop_person_id');



        foreach ($staffList as $key => $value) {
            $staffList[$key]['img'] = $shop_person_imgs[$value['id']] ?? '';

            if($value['station_name'] == '高级疤痘护理师' || $value['station_name'] == '中级疤痘护理师' || $value['station_name'] == '初级疤痘护理师'){
                $staffList[$key]['station_name'] = '特级疤痘护理师';
            }

            if($value['station_name'] == '高级项目护理师' || $value['station_name'] == '中级项目护理师' || $value['station_name'] == '初级项目护理师'){
                $staffList[$key]['station_name'] = '特级项目护理师';
            }
        }
        // echo "<pre>";
        // print_r($staffList);
        // echo "</pre>";
        // exit;



        
        
        return $staffList;

    }
}